<?php

namespace IDock\Printer\NonCar;

use IDock\Printer\BasePrinter;
use IDock\Visitor\NonCar\NonCarProductVisitor;

/**
 * 询价结果
 */
class NonCarInquiryPrinter extends BasePrinter
{
    /**
     * 非车保单集合
     * @var array $nonCarInquirySingle
     */
    public $nonCarInquirySingleList = [];

    /**
     * 总保费
     * @var string $totalPremium
     */
    public $totalPremium = 0;

    public function noCarInquirySingleAppend(NonCarInquirySinglePrinter  $printer)
    {
        $this->nonCarInquirySingleList[] = $printer;
    }

    /**
     * @return array
     */
    public function getNonCarInquirySingle(): array
    {
        return $this->nonCarInquirySingleList;
    }

    public function loadVisitor(array $array){
        /*** @var $visitor NonCarProductVisitor */
        foreach ($array as $visitor) {
            $single = new NonCarInquirySinglePrinter();

            foreach (array_keys(get_class_vars(NonCarInquirySinglePrinter::class)) as $var) {
                if (property_exists(NonCarProductVisitor::class,$var)) {
                    $single->$var = $visitor->$var;
                }
            }

            $this->nonCarInquirySingleList[] = $single;
        }
    }
}
